package com.lepu.app.fun.index.bean;

import java.io.Serializable;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

@SuppressWarnings("serial")
public class BeanIndexFileReport implements Serializable{

    public String reportId;
    public String reportContent;
    public String reportTime;
    public ArrayList<String> reportImageUrl; // 图片集合
  
    public static ArrayList<BeanIndexFileReport> parseJsonData(String dataString) {
    	ArrayList<BeanIndexFileReport> topicList = new ArrayList<BeanIndexFileReport>();
        try {
            JSONObject jsonObject = new JSONObject(dataString);
            JSONObject obj1 = (JSONObject) jsonObject.get("Result");
            JSONArray dataArray = obj1.getJSONArray("ListInfo");

            for(int i=0; i<dataArray.length(); i++){
				JSONObject focusJson = (JSONObject) dataArray.get(i);
				BeanIndexFileReport motherTopic = new BeanIndexFileReport();
				motherTopic.reportId = focusJson.optString("MRID");
				motherTopic.reportContent = focusJson.optString("Description");
				motherTopic.reportTime = focusJson.optString("UploadTime");
				motherTopic.reportImageUrl = parseJsonImage(focusJson.getJSONArray("ImgList"));
				
				
				topicList.add(motherTopic);
			}
        } catch (JSONException e) {
            e.printStackTrace();
        }
        
        return topicList;
    }

    //解析图片
    public static ArrayList<String> parseJsonImage(JSONArray jsonArray){
    	ArrayList<String> imageList = new ArrayList<String>();
    	for(int i=0; i<jsonArray.length(); i++){
			try {
				JSONObject jb = jsonArray.getJSONObject(i);
				imageList.add(jb.optString("ImagePath"));
			} catch (JSONException e) {
				e.printStackTrace();
			}
    	}
		return imageList;
    }
    
}
